#include <stdio.h>
static long num_steps = 10000000;
double step;
int pi(){
    int i; 
    double x, pi, sum = 0.0; 
    step = 1.0/(double) num_steps; 
    for (i=1;i<= num_steps; i++){ 
        x = (i-0.5)*step; 
        sum = sum + 4.0/(1.0+x*x);
    } 
    pi = step * sum;
    printf("pi = %.20lf\n",pi);

}

int main(int argc, char **argv){
    int threads[] = {2, 4, 6, 8, 10, 20, 30, 40};
    for(int i = 0; i < 8; i++){
        double start; 
        double end; 
        omp_set_threads(threads[i]);
        start = omp_get_wtime(); 
        pi();
        end = omp_get_wtime(); 
        printf("thread %d Work took %f seconds\n",threads[i], end - start);
    }
}